<?php
namespace app\index\controller;
use app\common\controller\Frontend;
use think\facade\Lang;
/**
 * Ajax异步请求接口
 * @internal
 */
class Ajax extends Frontend
{

    protected $noNeedLogin = ['lang'];
    protected $noNeedRight = ['*'];
    protected $layout = '';

    /**
    * 加载语言包
    * @method  post
    * @param   string  $username   用户名
    * @param   string  $password   密码
    * @param   int     $keeptime   有效时长
    * @return  数据列表返回
    * @returnparam tstr string 有效时长,低效时长 
    * @returnparam result tinyint 1,成功0，失败
    * @returnobject City
    * @returnparam stred tinyint 3,成功4，失败
    * @returnparam strcc string 字符串
    */
    public function lang()
    {
        header('Content-Type: application/javascript');
        $callback = $this->request->get('callback');
        $controllername = input("controllername");
        $this->loadlang($controllername);
        //强制输出JSON Object
        $result = jsonp(Lang::get(), 200, [], ['json_encode_param' => JSON_FORCE_OBJECT | JSON_UNESCAPED_UNICODE]);
        return $result;
    }
    
    /**
     * 上传文件
     */
    public function upload()
    {
        return action('api/common/upload');
    }

}
